using System;
using UnityEngine;
using UnityEngine.UI;

[Serializable]
[ExecuteInEditMode]
public class Testttttj : MonoBehaviour
{
	private Text gui;

	private float updateInterval;

	private double lastInterval;

	private int frames;

	public Testttttj()
	{
		updateInterval = 1f;
	}

	public void Start()
	{
		lastInterval = Time.realtimeSinceStartup;
		frames = 0;
	}

	public void OnDisable()
	{
		if ((bool)gui)
		{
			UnityEngine.Object.DestroyImmediate(gui.gameObject);
		}
	}

	public void Update()
	{
		frames++;
		float realtimeSinceStartup = Time.realtimeSinceStartup;
		if (!((double)realtimeSinceStartup <= lastInterval + (double)updateInterval))
		{
			if (!gui)
			{
				GameObject gameObject = new GameObject("FPS Display", typeof(Text));
				gameObject.hideFlags = HideFlags.HideAndDontSave;
				gameObject.transform.position = new Vector3(0f, 0f, 0f);
				gui = gameObject.GetComponent<Text>();
				RectTransform rt = gui.rectTransform;
				rt.anchoredPosition = new Vector2(100, 50);
				//gui.pixelOffset = new Vector2(5f, 55f);
			}
			float a = (float)((double)frames / ((double)realtimeSinceStartup - lastInterval));
			float num = 1000f / Mathf.Max(a, 1E-05f);
			gui.text = num.ToString("f1") + "ms " + a.ToString("f2") + "FPS";
			frames = 0;
			lastInterval = realtimeSinceStartup;
		}
	}

	public void Main()
	{
	}
}
